/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.base.db.impl;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.base.model.FinancialProject;
import com.yunhoo.base.db.dao.FinancialProjectDao;
import com.yunhoo.sys.db.util.DbTool;
import com.yunhoo.sys.util.common.LoginParam;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class FinancialProjectDaoImpl extends SqlMapDaoTemplate implements FinancialProjectDao {

    private static SqlMapClient sqlmap;
    private String nameSpace = "financialProject.";

    public FinancialProjectDaoImpl(DaoManager daoManager) {
        super(daoManager);
        sqlmap = DbTool.getSqlMapClient();
    }

    @Override
    public void insert(FinancialProject param) throws SQLException {
        System.out.println(nameSpace + "insert");
        sqlmap.insert(nameSpace + "insert", param);
    }

    @Override
    public void update(FinancialProject param) throws SQLException {
        System.out.println(nameSpace + "update");
        sqlmap.update(nameSpace + "update", param);
    }

    @Override
    public void delete(FinancialProject param) throws SQLException {
        System.out.println(nameSpace + "delete");
        sqlmap.delete(nameSpace + "delete", param);
    }

    @Override
    public void deleteById(FinancialProject param) throws SQLException {
        System.out.println(nameSpace + "deleteById");
        sqlmap.delete(nameSpace + "deleteById", param);
    }

    @Override
    public FinancialProject queryById(FinancialProject param) throws SQLException {
        System.out.println(nameSpace + "queryById");
        return (FinancialProject) sqlmap.queryForObject(nameSpace + "queryById", param);
    }

    @Override
    public List<FinancialProject> queryAll(FinancialProject param) throws SQLException {
        return sqlmap.queryForList(nameSpace + "queryAll", param);
    }

    @Override
    public FinancialProject nameRepeatForInsert(FinancialProject param) throws SQLException {
        System.out.println(nameSpace + "nameRepeatForInsert");
        return (FinancialProject) sqlmap.queryForObject(nameSpace + "nameRepeatForInsert", param);
    }

    @Override
    public FinancialProject nameRepeatForUpdate(FinancialProject param) throws SQLException {
        System.out.println(nameSpace + "nameRepeatForUpdate");
        return (FinancialProject) sqlmap.queryForObject(nameSpace + "nameRepeatForUpdate", param);
    }

    @Override
    public Integer maxCode() {
        System.out.println(nameSpace + "maxCode");
        Map map = new HashMap();
        map.put("orgCode", LoginParam.getOrg().getCode());
        map.put("iyear", LoginParam.getIyear());
        try {
            return (Integer) sqlmap.queryForObject(nameSpace + "maxCode", map);
        } catch (SQLException ex) {
            Logger.getLogger(FinancialProjectDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
}
